package com.kaoshi.jeeweb.common.persistence.base;

import com.kaoshi.jeeweb.common.entity.AbstractEntity;
import com.kaoshi.jeeweb.common.persistence.BaseEntity;
import com.kaoshi.jeeweb.common.persistence.DataEntity;
import com.kaoshi.myweb.common.seachable.QueryCondition;
import com.kaoshi.myweb.common.seachable.UpdateCondition;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;
import java.util.List;

public interface BaseGenericDao<T extends DataEntity, PK extends Serializable> {

	String CRITERIA_KEY = "condition";

	String ENTITY_KEY = "entity";

	List<T> queryAll();

	int insert(T t);

	boolean deleteById(PK id);

	T queryById(PK id);

	int updateById(@Param(value = ENTITY_KEY) T t);

	long count();

	List<T> queryByCondition(@Param(value = CRITERIA_KEY) QueryCondition condition);

	long countByCondition(@Param(value = CRITERIA_KEY) QueryCondition condition);

	int updateByCondition(@Param(value = ENTITY_KEY) T t, @Param(value = CRITERIA_KEY) UpdateCondition condition);

	int deleteByCondition(@Param(value = CRITERIA_KEY) UpdateCondition condition);
}
